package com.mxl.mvc.cashorder;

import javax.servlet.http.HttpServletRequest;

import org.apache.commons.lang.StringUtils;

import com.mxl.common.StringUtil;
import com.mxl.common.helper.ResponseErrorCode;

/**
 * 业务验证
 * 
 * @author Administrator
 * 
 */
public class GatewayRequestValidate {

	public static String checkRequest(HttpServletRequest request) {
		String msgId = null;
		String orderId = request.getParameter("order_id");
		String merchantAcctId = request.getParameter("member_code");
		String orderAmount = request.getParameter("order_amount");
		String url = request.getParameter("notify_url");
		if (StringUtils.isEmpty(orderId)) {
			msgId = ResponseErrorCode.ORDERID_IS_NULL.getValue();
		} else if (StringUtils.isEmpty(merchantAcctId)) {
			msgId = ResponseErrorCode.MEMBERCODE_IS_NULL.getValue();
		} else if (StringUtils.isEmpty(orderAmount)) {
			msgId = ResponseErrorCode.ORDERAMOUNT_IS_NULL.getValue();
		} else if (!StringUtil.isNumber(orderAmount)) {
			msgId = ResponseErrorCode.ORDERAMOUNT_IS_NOT_NUMBER.getValue();
		} else if (StringUtils.isEmpty(url)) {
			msgId = ResponseErrorCode.NOTIFY_URL_ISNULL.getValue();
		}
		return msgId;
	}
}
